import re

import requests

from config import headers
from utils.download_tools import download_imgs
from utils.image_util import save_jpgs, download_save_jpgs


def download(url: str):
    html = requests.get(url, headers=headers).text

    title = re.findall('class="article mbottom10">(.+?)<', html)[0].split(' ')[0]
    img_urls = re.findall('href="javascript:;"><img src="(.+?)"', html)

    download_save_jpgs(img_urls, title)


if __name__ == '__main__':
    id = '133971'
    prefix = 'http://ciyuandao.com/photo/show/'
    download(prefix+id)
